*** NOTE:  This do-file performs the MSA-level refinance FRM specifications in Table 6a. ***
***        If an MSA's specfication did not converge using the MNL model with unobseved  ***
***        heterogeneity in this do-file, that MSA's analysis was performed using the    ***
***        constant heterogeneity weight approach found in the do-file named "Table 6    ***
***        constant mass point -- refi_frm.                                              ***



log using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Logs\20101016 mymlogit_uh_lf by msa -- full size -- refi_frm.log", replace



program mymlogit_uh_lf
	version 10.1
	args lnf bxj1 bxj2 loc_j1_l1 loc_j1_l2 mass_point loc_j2_l1 loc_j2_l2
	tempvar denom_l1 denom_l2 mass_prob_l1 mass_prob_l2
	quietly generate double `denom_l1' = 1 + exp(`bxj1' + `loc_j1_l1') + exp(`bxj2' + `loc_j2_l1')
	quietly generate double `denom_l2' = 1 + exp(`bxj1' + `loc_j1_l2') + exp(`bxj2' + `loc_j2_l2')

	quietly generate double `mass_prob_l1' = exp(`mass_point') / (1 + exp(`mass_point'))
	quietly generate double `mass_prob_l2' = 1 / (1 + exp(`mass_point'))


	quietly replace `lnf' = ln((`mass_prob_l1'*(1/`denom_l1')) + (`mass_prob_l2'*(1/`denom_l2'))) if $ML_y1 == 0
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj1' + `loc_j1_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj1' + `loc_j1_l2')/`denom_l2'))) if $ML_y1 == 1
	quietly replace `lnf' = ln((`mass_prob_l1'*(exp(`bxj2' + `loc_j2_l1')/`denom_l1')) + (`mass_prob_l2'*(exp(`bxj2' + `loc_j2_l2')/`denom_l2'))) if $ML_y1 == 2
end



*****************
*** Atlanta   ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Atlanta\atlanta_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", replace onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", replace onecol text bracket(se) e(all)
*ml graph






*****************
*** Baltimore ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Baltimore\baltimore_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






*****************
*** Chicago   ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Chicago\chicago_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






******************
*** LosAngeles ***
*** refi_frm  ***
******************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\LosAngeles\losangeles_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






*****************
*** Miami     ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Miami\miami_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






*******************
*** Minneapolis ***
*** refi_frm   ***
*******************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Minneapolis\minneapolis_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






*****************
*** NewYork   ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\NewYork\newyork_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






*****************
*** Phoenix   ***
*** refi_frm ***
*****************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Phoenix\phoenix_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






******************
*** Pittsburgh ***
*** refi_frm  ***
******************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\Pittsburgh\pittsburgh_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph






******************
*** SanAntonio ***
*** refi_frm  ***
******************

use "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Data\MSA Level\SanAntonio\sanantonio_both_refi_frm generated.dta", clear

*** Generating matrix of starting values using mlogit ***
mlogit outcome_a prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006 if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mlogit by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
do "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic Consistency\Stata\Stata Do-files\mymlogit_uh_lf\creating starter matrix for mymlogit_uh_lf.do"

*** Running mymlogit_uh_lf ***
ml model lf mymlogit_uh_lf (default: outcome_a = prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (payoff: prepay_pen prepay_pen_end balloon lownodoc cashout fico cltv refi_premium ageofloan ageofloan_2 rel_loan_size chg_unempl var_hpi var_fixed vint2003 vint2004 vint2005 vint2006, noconstant) (default_const1:) (default_const2:) (prob_coeff1:) (payoff_const1:) (payoff_const2:) if outsample_a != 1 & fico > 0 & cltv != 0 & balance != 0, cluster(loan_id_num)
*ml check
ml init starter, copy
ml maximize, iterate(1000) difficult
outreg2 using "C:\Documents and Settings\morgan.rose\My Documents\Foreclosure\Geographic consistency\Stata\Stata Outregs\20101016 mymlogit_uh_lf by MSA full size refi_frm.txt", append onecol text bracket(se) e(all)
*ml graph



program drop mymlogit_uh_lf



log close



clear



